home *** CD-ROM | disk | FTP | other *** search
/ CD World Haziran 1997 / CD World Haziran 1997.iso / Explorer Yardimcilari / PiXCL Tools / Registry.px_ / Registry.px
Encoding:
PiXCL source  |  1996-07-11  |  5.4 KB  |  217 lines

  1. Initialize:
  2.     WinGetActive(Win$)
  3.     UseCoordinates(PIXEL)
  4.     UseBackGround(TRANSPARENT,192,192,192)
  5.     DrawBackGround
  6.     WaitInput(100)  {let NT and 95 catch up}
  7.     InfoMenu(REMOVE)
  8.     SetMenu()
  9.     WinLocate(Win$,250,10,620,240,Res) 
  10.     Title$ = "Windows Registry Commands"
  11.     WinTitle(Win$, Title$)
  12.     WinShow(Title$,NOTOPMOST,Res)
  13.     DirGet(SourceDir$)
  14.  
  15.  
  16.     SetMenu("E&xit!",Leave,
  17.         ENDPOPUP,
  18.         "&Registry",IGNORE,
  19.         "&Open PiXCL4.0 Key",Open_Key,
  20.         "&Enum PiXCL4.0 Key",Enum_Key,
  21.         "&Close PiXCL4.0 Key",Close_Key,
  22.         SEPARATOR,
  23.         "&Add PiXCL4.0 Key",Create_Key,
  24.         "&Delete PiXCL4.0 Key",Delete_Key,
  25.         SEPARATOR,
  26.         "&Query PiXCL4.0 Key",QueryKey,
  27.         "&Query PiXCL4.0 Key Value",QueryValue,
  28.         ENDPOPUP,
  29.         "&Help",IGNORE,
  30.         "&Information",Info,
  31.         "&View PXL source",ViewSource,
  32.         SEPARATOR,
  33.         "&About",About,
  34.         ENDPOPUP)
  35.     
  36. Wait_for_Input:
  37.     WaitInput()
  38.  
  39.  
  40. Leave:
  41.     End
  42.  
  43.  
  44. Info:
  45.     MessageBox(OK,1,INFORMATION,
  46. "This sample program shows you how to access the Registry.
  47. We suggest that you look at the PiXCL code first to see
  48. what is displayed as results in the client area. There are
  49. also comments in the PXL source that explain more fully
  50. what is happening.
  51.  
  52. To use this sample program, you must first create some
  53. entries in the Registry with the 'Create' menu item. Once
  54. entries are created, start up Windows REGEDIT and look in
  55. the HKEY_CLASSES_ROOT for the 'PiXCL4.0' entries.
  56.  
  57. The 'Open' menu item will now return success. Try the 
  58. 'Query' menu item and see that the information returned 
  59. is the same as you see with REGEDIT.
  60.  
  61. Please TAKE CARE accessing the Registry: trial and error 
  62. changes can result in a corrupted database, and a reload
  63. of all software may be necessary.",
  64.     "Using the Registry Access Sample program",Res)
  65.  
  66.     Goto Wait_for_Input
  67.  
  68.  
  69. ViewSource:
  70.     PXLfile$ = SourceDir$ + "\registry.pxl"
  71.     CmdLine$ = "Notepad " + PXLfile$
  72.     Run(CmdLine$)
  73.     Goto Wait_for_Input
  74.  
  75.  
  76. About:
  77.     AboutUser("PiXCL 4.0 Sample Program",
  78.           "Reading and Writing the Windows Registration Database.",
  79. "This sample program will create, read and delete 
  80. specific sample entries for PiXCL 4.0 in the Registry.
  81. No existing entries are accessed or changed.")
  82.     Goto Wait_for_Input
  83.  
  84. Open_Key:
  85.     DrawBackground
  86.     RDBOpenKey(@RDB_CLASSES_ROOT,"PiXCL4.0",Handle)
  87.     DrawNumber(10,10,Handle)
  88.     
  89.     Goto Wait_for_Input
  90.  
  91. QueryKey:
  92.     DrawBackground
  93.     RDBQueryKey(Handle,Class$, NumKeys, NumValues, Res)
  94.     If Class$ = "" Then Class$ = "Class$ returns NULL"
  95.     DrawText(10,10,Class$)
  96.     DrawNumber(10,30,NumKeys)
  97.     DrawNumber(10,50,NumValues)
  98.  
  99.     Goto Wait_for_Input
  100.  
  101.  
  102. QueryValue:
  103.     DrawBackground
  104.     RDBOpenKey(Handle,"DefaultIcon",IconHandle)
  105.     RDBOpenKey(Handle,"Image Formats",FMTHandle)
  106.     RDBOpenKey(Handle,"Properties",PtyHandle)
  107.  
  108.     RDBQueryValue(IconHandle,"",Value1$,Res) {gets "(Default)" value string}
  109.     RDBQueryValue(IconHandle,"SecondIcon",Value2$,Res) {gets specific value string}
  110.     RDBQueryValue(FMTHandle,"Type2",Value3$,Res) {gets specific value}
  111.  
  112.     RDBQueryValue(PtyHandle,"Type1",Value4$,Res) {gets specific value}
  113.  
  114.     DrawText(10,10,Value1$)
  115.     DrawText(10,35,Value2$)
  116.     DrawText(10,60,Value3$)
  117.     DrawText(10,85,Value4$)
  118.     Goto Wait_for_Input
  119.  
  120.  
  121. Close_Key:
  122.     DrawBackground
  123.     RDBCloseKey(Handle,Res)
  124.     DrawNumber(10,10,Res)
  125.     
  126.     Goto Wait_for_Input
  127.  
  128.  
  129. Create_Key:
  130.     DrawBackground
  131.     RDBCreateKey(@RDB_CLASSES_ROOT,"PiXCL4.0","",Handle,Res)
  132.     RDBCreateKey(Handle,"DefaultIcon","",PXL40IconHandle,Res)
  133.  
  134.     {In next, note NULL string, Handle defines location. This will add the 
  135.       value string to the "(Default)" Handle entry in the registry}
  136.  
  137.     RDBSetValue(PXL40IconHandle,"", "h:\p40tools\pdk\PiXCL.exe,1",STRING,Res)
  138.  
  139.     RDBSetValue(PXL40IconHandle,"SecondIcon", {note new item in "DefaultIcon" tree}
  140.             "h:\p40tools\pdk\PiXCL.exe,2",STRING,Res)
  141.  
  142.     RDBCreateKey(Handle,"Properties","",PXLPropHandle,Res)
  143.     RDBSetValue(PXLPropHandle,"Type1","256",DWORD,Res)
  144.  
  145.     RDBCreateKey(Handle,"Image Formats","",PXLImgHandle,Res)
  146.     RDBSetValue(PXLImgHandle,"Type2","BMP|RLE|PNG|JPG|",LIST,Res)
  147.  
  148.  
  149.  
  150.     If Res <= 1
  151.         DrawNumber(10,10,Handle)
  152.         DrawNumber(10,35,Res)
  153.     Else
  154.        DrawText(10,10,"Entry already exists")
  155.        DrawNumber(10,35,Handle)
  156.     Endif
  157.     
  158.     Goto Wait_for_Input 
  159.  
  160. Delete_Key:
  161.     DrawBackground
  162.     RDBDeleteKey(@RDB_CLASSES_ROOT,"PiXCL4.0",Res)
  163.     {RDBDeleteKey(Handle,"PiXCL4.0",Res)} {fails, key$ is not subkey of handle}
  164.     DrawNumber(10,10,Res)
  165.  
  166.     
  167.     Goto Wait_for_Input
  168.  
  169. Enum_Key:
  170.     DrawBackground
  171.     Index = 0
  172.     RDBEnumKey(Handle,0,SubKey$,Class$,Res)
  173.     DrawText(10,10,SubKey$)
  174.     If Class$ = "" Then Class$ = "Class$ returns NULL"
  175.     DrawText(10,30,Class$)
  176.  
  177.     RDBEnumKey(Handle,1,SubKey$,Class$,Res)
  178.     DrawText(10,50,SubKey$)
  179.     If Class$ = "" Then Class$ = "Class$ returns NULL"
  180.     DrawText(10,70,Class$)
  181.  
  182.     RDBEnumKey(Handle,2,SubKey$,Class$,Res)
  183.     DrawText(10,90,SubKey$)
  184.     If Class$ = "" Then Class$ = "Class$ returns NULL"
  185.     DrawText(10,110,Class$)
  186.  
  187.     {This should result in a "no more entries" Result=2}
  188.     RDBEnumKey(Handle,3,SubKey$,Class$,Res)
  189.     DrawNumber(230,150,Res)
  190.     If SubKey$ = "" Then SubKey$ = "SubKey$ returns NULL"
  191.     DrawText(25,130,SubKey$)
  192.     If Class$ = "" Then Class$ = "Class$ returns NULL"
  193.     DrawText(25,150,Class$)
  194.  
  195.  
  196.  
  197.     Goto Wait_for_Input
  198.  
  199. EnumLoop:
  200.     RDBEnumKey(Handle,Index,SubKey$,Class$,Res)
  201.     DrawBackGround    WaitInput(400)
  202.     DrawNumber(10,0,Res)
  203.     DrawText(10,20,SubKey$)
  204.     DrawText(10,40,Class$)
  205.     Index = Index + 1
  206.     If Res <> 2 Then Goto EnumLoop
  207.  
  208.  
  209.     Goto Wait_for_Input
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.